package com.ruoyi.Warehouse.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.Warehouse.domain.Inventorytransactions;
import com.ruoyi.Warehouse.service.IInventorytransactionsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 库存交易记录表Controller
 * 
 * @author ruoyi
 * @date 2025-06-16
 */
@Controller
@RequestMapping("/pims/inventorytransactions")
public class InventorytransactionsController extends BaseController
{
    private String prefix = "pims/inventorytransactions";

    @Autowired
    private IInventorytransactionsService inventorytransactionsService;

    @RequiresPermissions("pims:inventorytransactions:view")
    @GetMapping()
    public String inventorytransactions()
    {
        return prefix + "/inventorytransactions";
    }

    /**
     * 查询库存交易记录表列表
     */
    @RequiresPermissions("pims:inventorytransactions:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(Inventorytransactions inventorytransactions)
    {
        startPage();
        List<Inventorytransactions> list = inventorytransactionsService.selectInventorytransactionsList(inventorytransactions);
        return getDataTable(list);
    }

    /**
     * 导出库存交易记录表列表
     */
    @RequiresPermissions("pims:inventorytransactions:export")
    @Log(title = "库存交易记录表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Inventorytransactions inventorytransactions)
    {
        List<Inventorytransactions> list = inventorytransactionsService.selectInventorytransactionsList(inventorytransactions);
        ExcelUtil<Inventorytransactions> util = new ExcelUtil<Inventorytransactions>(Inventorytransactions.class);
        return util.exportExcel(list, "库存交易记录表数据");
    }

    /**
     * 新增库存交易记录表
     */
    @RequiresPermissions("pims:inventorytransactions:add")
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存库存交易记录表
     */
    @RequiresPermissions("pims:inventorytransactions:add")
    @Log(title = "库存交易记录表", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(Inventorytransactions inventorytransactions)
    {
        return toAjax(inventorytransactionsService.insertInventorytransactions(inventorytransactions));
    }

    /**
     * 修改库存交易记录表
     */
    @RequiresPermissions("pims:inventorytransactions:edit")
    @GetMapping("/edit/{transactionId}")
    public String edit(@PathVariable("transactionId") Long transactionId, ModelMap mmap)
    {
        Inventorytransactions inventorytransactions = inventorytransactionsService.selectInventorytransactionsByTransactionId(transactionId);
        mmap.put("inventorytransactions", inventorytransactions);
        return prefix + "/edit";
    }

    /**
     * 修改保存库存交易记录表
     */
    @RequiresPermissions("pims:inventorytransactions:edit")
    @Log(title = "库存交易记录表", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(Inventorytransactions inventorytransactions)
    {
        return toAjax(inventorytransactionsService.updateInventorytransactions(inventorytransactions));
    }

    /**
     * 删除库存交易记录表
     */
    @RequiresPermissions("pims:inventorytransactions:remove")
    @Log(title = "库存交易记录表", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(inventorytransactionsService.deleteInventorytransactionsByTransactionIds(ids));
    }
}
